﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Comdiv.Dbfs;
using Comdiv.Inversion;
using Comdiv.Persistence;

namespace dbfsupload
{
    class Program
    {
        static void Main(string[] args)
        {
            ioc.Container.setupHibernate(new NamedConnection("dbfs",
                                                             "Data Source=(local);Integrated Security=True;Initial Catalog=dbfs"),
                                                             new DbfsModel());
            var uploader = new DbfsRepository{System = "local"};
            IDictionary<string,string> tags = new Dictionary<string, string>();
            var hasher = System.Security.Cryptography.MD5.Create();
            var code = Convert.ToBase64String( hasher.ComputeHash(Encoding.UTF8.GetBytes(args[0])));
            if(args.Length>1){
                foreach (var p in args.Skip(1)){
                    tags[p.Split(':')[0]] = p.Split(':')[1];
                }
            }
            uploader.Define(code, args[0], System.IO.File.ReadAllBytes(args[0]), tags);
            Console.WriteLine("Файл прокачен!");
        }
    }
}
